class MigrateFunctions < ActiveRecord::Migration
  
  class << self
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Database create/drop methods
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def up
      create_functions_table
    end

    def down
      drop_functions_table
    end

    private
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # Table create/drop methods
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
      def create_functions_table
        create_table_with_privies(:functions, :force => true) do |t|
          t.column("name", :text, :null => false)
          t.column("ctroller", :text, :null => false)
          t.column("action", :text, :null => false)
        end
        #
        # Use this for adding features to the site that require custom coding.
        # Actions in the functions table can be added to the folders for access which
        # allows the admin of the site to customize the menu.
        #
        # Examples:
        # => Function.create(:name => "Employee List", :ctroller => "/employees", :action => "list")
        # => Function.create(:name => "Org Chart", :ctroller => "/org_chart", :action => "index")
        # => Function.create(:name => "List Jobs", :ctroller => "/jobs", :action => "list")

        create_lookup_table(:folders,:functions)
      end

      def drop_functions_table
        drop_lookup_table(:folders,:functions)
        drop_table(:functions)
      end
  end #end class block
end
